package pack0910;

import java.util.Scanner;

// if-else
public class DemoJ {

    //练习1：用户输入一个数，判断其是否是同时被3和5整除。如果是，则输出YES，否则输出NO。
    public static void a1() {
        Scanner scan = new Scanner(System.in);
        System.out.print("Input:");
        int number = scan.nextInt();
        if ((number % 5 == 0) && (number % 3 == 0)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void a2() {
        Scanner scan = new Scanner(System.in);
        System.out.print("Input:");
        int number = scan.nextInt();
        if ((number % 5 == 0) && (number % 3 == 0)) {
            System.out.println("YES");
            return; // 当前函数代码执行完毕
        }
        System.out.println("NO");
    }

    // 练习2：用户输入一个四位数，判断其是否是对称数。如果是，则输出YES，否则输出NO。例如：4224就是对称数。
    public static void b() {
        Scanner scan = new Scanner(System.in);
        System.out.print("Input:");
        int number = scan.nextInt();
        if (number > 9999 || number < 1000) {
            System.out.println(number + "不是一个四位数！");
            return;
        }
        int gewei = number % 10;
        int qianwei = number / 1000;
        int baiwei = number / 100 % 10;
        int shiwei = number / 10 % 10;
        if (gewei != qianwei || shiwei != baiwei) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
    }

    // 练习3：用户输入一个用24小时制表示的时间，把它转换为用12小时制表示的时间并输出。如：输入1807（18点07分），则输出06:07PM
    public static void c() {
        Scanner scan = new Scanner(System.in);
        System.out.print("Input:");
        int time = scan.nextInt();
        int hour = time / 100;
        int minute = time % 100;
        if (hour > 23 || hour < 0 || minute > 59 || minute < 0) {  // 1167-->1207   2509-->0109
            System.out.println("输入的时间不合法！");
            return;
        }
        if (hour > 11) {
            hour -= 12;
            System.out.println((hour < 10 ? ("0" + hour) : (hour)) + ":" + ((minute < 10) ? ("0" + minute) : (minute)) + "PM");
        } else {
            System.out.println((hour < 10 ? ("0" + hour) : (hour)) + ":" + ((minute < 10) ? ("0" + minute) : (minute)) + "AM");
        }
    }

    // 练习4：用户输入一个三位数，判断这个数是否时水仙花数。(水仙花数是指一个 3位数，它的每个位上的数字的 3次幂之和等于它本身（例如：1^3 + 5^3+ 3^3 = 153）)
    public static void d() {
        Scanner scan = new Scanner(System.in);
        System.out.print("Input:");
        int number = scan.nextInt();
        if (number > 999 || number < 100) {
            System.out.println(number + "不是三位数！");
            return;
        }
        int gewei = number % 10;
        int shiwei = number / 10 % 10;
        int baiwei = number / 100;
        if ((gewei * gewei * gewei + shiwei * shiwei * shiwei + baiwei * baiwei * baiwei) == number) {
            System.out.println(number + "是水仙花数！");
        } else {
            System.out.println(number + "bu是水仙花数！");
        }
    }

    public static void main(String[] args) {
        d();
    }
}